from collections import deque

"""
    search_queue = deque()
    search_queue.append("q")
    search_queue.append("w")
    search_queue.append("e")
    search_queue.append("r")
    search_queue.pop()
    
    print(search_queue)
    
    out:
        deque(['q', 'w', 'e'])
"""


def check(name):
    return name == 'tunm'


def search(name):
    search_queue = deque()
    search_queue += graph[name]
    searched = []
    while search_queue:
        person = search_queue.popleft()
        if person not in searched:
            if check(person):
                print('find tunm!')
                return True
            else:
                search_queue += graph[person]
                searched.append(person)
    return True


graph = {}
graph['you'] = ['alice', 'bob', 'claire']
graph['bob'] = ['anuj', 'peggy']
graph['alice'] = ['peggy']
graph['claire'] = ['tunm', 'jonny']
graph['anuj'] = []
graph['peggy'] = []
graph['tunm'] = []
graph['jonny'] = []

search('you')
